<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ToyoMotor
 *
 * @author Desarrollo 2
 */
class ToyoMotor {
    //put your code here
    static public function slugify($text)
    {
        //$text = utf8_encode($text);
        // replace all non letters or digits by -
    	//$text = preg_replace('/\W+/', '-', $text);
	$arr_busca = array(' ','á','à','â','ã','ª','Á','À',
		'Â','Ã', 'é','è','ê','É','È','Ê','í','ì','î','Í',
		'Ì','Î','ò','ó','ô', 'õ','º','Ó','Ò','Ô','Õ','ú',
		'ù','û','Ú','Ù','Û','ç','Ç','Ñ','ñ','.');
		$arr_susti = array('-','a','a','a','a','a','A','A',
		'A','A','e','e','e','E','E','E','i','i','i','I','I',
		'I','o','o','o','o','o','O','O','O','O','u','u','u',
		'U','U','U','c','C','N','n','');
		//$text = trim(str_replace($arr_busca, $arr_susti, $text));
	$text = preg_replace("[ÁÀÂÃ]","A",$text);
	$text = preg_replace("[áàâãª]","a",$text);
	$text = preg_replace("[ÉÈÊ]","E",$text);
	$text = preg_replace("[éèê]","e",$text);
	$text = preg_replace(array("/Í/","/Ì/","/Î/"),"I",$text);
	$text = preg_replace(array("/í/","/ì/","/î/"),"i",$text);
	$text = preg_replace("[ÓÒÔÕ]","O",$text);
	$text = preg_replace("[óòôõº]","o",$text);
	$text = preg_replace("[ÚÙÛ]","U",$text);
	$text = preg_replace("[úùû]","u",$text);
	$text = str_replace("Ç","C",$text);
	$text = str_replace("ç","c",$text);
	//$text = preg_replace('/\W+/', '-', $text);

	//$text_final = ereg_replace('[^A-Za-z0-9\_\.\-]', '', $text);
	$text_final = ereg_replace('[^A-Za-z0-9\_\-]', '-', $text);

    	// trim and lowercase
    	$text_final = strtolower(trim($text_final, '-'));

    	return $text_final;
  	}
}
?>
